﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;

namespace QLTV_Data
{
   public class Lop_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_tbl_Lop");
       }
       public DataTable taoBang(string sql)
       {
           return kn.taobang(sql);
       }
       public int insert_Lop(Lop_Public tenLop,Lop_Public maDonVi,Lop_Public khoaHoc,Lop_Public ghiChu)
       {
           int Nparameter = 4;
           string[]name=new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@TenLop";
           value[0] = tenLop.TenLop;
           name[1] = "@MaDonVi";
           value[1] = maDonVi.MaDonVi;
           name[2] = "@KhoaHoc";
           value[2] = khoaHoc.KhoaHoc;
           name[3] = "@GhiChu";
           value[3] = ghiChu.GhiChu;
           return kn.update("Insert_Lop",name,value,Nparameter);
       }
       public int update_Lop(Lop_Public maLop,Lop_Public tenLop, Lop_Public maDonVi, Lop_Public khoaHoc, Lop_Public ghiChu)
       {
           int Nparameter = 5;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaLop";
           value[0] = maLop.MaLop;
           name[1] = "@TenLop";
           value[1] = tenLop.TenLop;
           name[2] = "@MaDonVi";
           value[2] = maDonVi.MaDonVi;
           name[3] = "@KhoaHoc";
           value[3] = khoaHoc.KhoaHoc;
           name[4] = "@GhiChu";
           value[4] = ghiChu.GhiChu;
           return kn.update("Update_Lop", name, value, Nparameter);
       }
       public int delete_Lop(Lop_Public maLop)
       {
           int Nparameter = 1;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaLop";
           value[0] = maLop.MaLop;
           return kn.update("Delete_Lop", name, value, Nparameter);
       }
    }
}
